#
# Copyright © 2021 深圳百问网科技有限公司 All Rights Reserved.
# https://www.100ask.net
# https://shop502068889.taobao.com/
#
# SPDX-License-Identifier: BSD-3-Clause
#
 
from machine import Pin
from time import sleep
import dht 

sensor = dht.DHT11(Pin(14))

while True:
  try:
    sleep(2)
    sensor.measure()
    temp = sensor.temperature()
    hum = sensor.humidity()
    temp_f = temp * (9/5) + 32.0
    print('Temperature: %3.1f C' %temp)
    print('Temperature: %3.1f F' %temp_f)
    print('Humidity: %3.1f %%' %hum)
  except OSError as e:
    print('Failed to read sensor.')
